<p class="title">Example using the default setup</p>
<p>Parsing HTML using the default setup is as easy as creating a PDF in five steps:</p>
<ol>
<li>Create a <code>Document</code> object</li>
<li>Get a <code>PdfWriter</code> instance.</li>
<li>Open the <code>Document</code></li>
<li>Invoke <code>XMLWorkerHelper.getInstance().parseXHtml()</code></li>
<li>Close the <code>Document</code></li>
</ol>
<p>Let's take a look at a code snippet that converts the <a href="http://tutorial.itextpdf.com/src/main/resources/html/walden.html">walden.html</a> file to PDF.
In this snippet we use the <code>XMLWorkerHelper</code> class and its <code>parseXHtml()</code> method to do all the work:</p>
<pre code="java">
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document,
        new FileOutputStream("results/walden1.pdf"));
    document.open();
    XMLWorkerHelper.getInstance().parseXHtml(writer, document,
        HTMLParsingDefault.class.getResourceAsStream("/html/walden.html"), null);
    document.close();
</pre>
<p class="caption">see <a href="http://tutorial.itextpdf.com/src/main/java/tutorial/xmlworker/HTMLParsingDefault.java">HTMLParsingDefault</a>
and the resulting PDF <a href="http://tutorial.itextpdf.com/results/xmlworker/walden1.pdf">walden1.pdf</a></p>
<p>The HTML was taken from <a href="http://www.gutenberg.org/wiki/Main_Page">project Gutenberg</a>. It's a book by H.D. Thoreau: Walden, or Life in the Woods.</p>
<p>When we look at the first page that is generated by iText, we see that something went wrong: the first lines on the HTML result in a line of gibberish. What went wrong and how can we fix it?</p>